
{template 'common/header'}
{template 'nav'}
{php load()->func('tpl')}
<script src="{MODULE_URL}template/js/galleria.js"></script>
<style type="text/css">
    #galleria img{
   display: block; position: relative; left: 50px; top: 30px;
   height: 0px;
   width: 0px;
}
</style>
<div class="main" id='list'>
{if $op == 'post'}
	<ul class="nav nav-tabs">
		<li><a href="{php echo $this->createWebUrl('houselease', array('regionid'=>$_GPC['regionid']));}">管理</a></li>
		<li class="active"><a href="{php echo $this->createWebUrl('houselease', array('op' => 'post','regionid'=>$_GPC['regionid'], 'id'=>$item['id']));}">编辑</a></li>
	</ul>
	<form action="" class="form-horizontal form" method="post">
	<div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">房屋租赁信息</h3>
          </div>
          <div class="panel-body">
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">状态</label>
                <div class="col-sm-10">
                  <select name="status" class="form-control">
                        <option value="0" {if intval($item[ 'status'])==0} selected{/if}>未解决</option>
                        <option value="1" {if intval($item[ 'status'])==1} selected{/if}>已解决</option>
                        <option value="2" {if intval($item[ 'status'])==2} selected{/if}>已撤销</option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">请选择房屋租赁分类</label>
                <div class="col-sm-10">
                  <select name="category" class="form-control">
                        {loop $categories $category}
                        <option value="{$category['name']}" {if $category[ 'name']==$item[ 'category']} selected{/if}>{$category['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">发布人</label>
                <div class="col-sm-10">
                	<input type="text" value="{$member['realname']}" class="form-control" readonly="readonly"/>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">发布时间</label>
                <div class="col-sm-10">
                	<input type="text" value="{php echo date('Y-m-d h:i:s', $item['createtime'])}" class="form-control" readonly="readonly"/>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">联系方式</label>
                <div class="col-sm-10">
                   <label for="contacttype1" class="radio radio-inline">
						<input type="radio" name="contacttype" id="contacttype1" value="1" {if $item['contacttype']==1}checked='checked'{/if}/>随时联系
						<input type="hidden" name="contactdesc[1]" value="随时联系"/>
					</label>
					<label for="contacttype2" class="radio radio-inline">
						<input type="radio" name="contacttype" id="contacttype2" value="2" {if $item['contacttype']==2}checked='checked'{/if}/>白天联系
						<input type="hidden" name="contactdesc[2]" value="白天联系"/>
					</label>
					<label for="contacttype3" class="radio radio-inline">
						<input type="radio" name="contacttype" id="contacttype3" value="3" {if $item['contacttype']==3}checked='checked'{/if}/>晚上联系
						<input type="hidden" name="contactdesc[3]" value="晚上联系"/>
					</label>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">要求</label>
                <div class="col-sm-10">
                   <textarea style="height:150px;" class="form-control" name="requirement" cols="70">{$item['requirement']}</textarea>
                </div>
            </div>
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">备注</label>
                <div class="col-sm-10">
                   <textarea style="height:100px;" class="form-control" name="remark" cols="70" id="remark" >{$item['remark']}</textarea>
                </div>
            </div>
            {if $imgs}
            <div class="form-group">
                <label for="" class="col-sm-2 control-label">房屋图片</label>
                <div class="col-sm-10">
                   {loop $imgs $value}
                        <img src="{$value['src']}" style="width: 60px; height: 60px;border:1px solid white;" />
                    {/loop}
                </div>
            </div>
            {/if}
            <div class="form-group">
                <label for="" class="col-sm-2 control-label"></label>
                <div class="col-sm-10">
                   <button type="submit" class="btn btn-primary span3" name="submit" value="提交">提交</button>
					<input type="hidden" name="token" value="{$_W['token']}" />
                </div>
            </div>
          </div>
        </div>
	</form>
	<div id="galleria"></div>
    <script>
    // Load theme
    Galleria.loadTheme('{MODULE_URL}template/lightbox/galleria.lightbox.js');

    $('#galleria').galleria({
        data_source: '#list',
        extend: function() {
            this.bind(Galleria.LOADFINISH, function(e) {
                $(e.imageTarget).click(this.proxy(function(e) {
                    e.preventDefault();
                    this.next();
                }))
            })
        },
        keep_source: true,
        data_config: function(img) {
            return {
                description: $(img).next('.caption').html()
            }
        }
    });
</script>
{elseif $op == 'display'}
	<ul class="nav nav-tabs">
		<li class="active"><a href="{php echo $this->createWebUrl('houselease', array('regionid'=>$_GPC['regionid']));}">管理</a></li>
	</ul>
	<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="" method="post" class="form-horizontal" role="form">
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 control-label">租赁分类</label>
					<div class="col-sm-8 col-md-8 col-lg-8 col-xs-12">
						<select class="form-control" id="cate_2" name="servicesmallcategory">
							<option value="0">请选择租赁分类</option>
							{loop $categories $key $category}
							<option value="{$category['name']}" {if $category['name'] == $_GPC['servicesmallcategory']} selected="selected"{/if}>{$category['name']}</option>
							{/loop}
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 control-label">发布日期</label>
					<div class="col-sm-8 col-md-8 col-lg-8 col-xs-12">
						{php echo tpl_form_field_daterange('birth', array('starttime' => $item['starttime'],'endtime' => $item['endtime']));}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-2 col-md-2 control-label">状态</label>
					<div class="col-sm-8 col-md-8 col-lg-8 col-xs-12">
						<label for="ipt_status1" class="radio-inline">
							<input name="status" id="ipt_status1" type="radio" value="0" {if @in_array(0, $status) || empty($status)}checked='checked'{/if} />未完成
						</label>
						<label for="ipt_status2" class="radio-inline">
							<input name="status" id="ipt_status2" type="radio" value="1" {if @in_array(1, $status)}checked='checked'{/if} />已完成
						</label>
						<label for="ipt_status3" class="radio-inline">
							<input name="status" id="ipt_status3" type="radio" value="2" {if @in_array(2, $status)}checked='checked'{/if} />已撤销
						</label>
					</div>
				</div>
				<div class="form-group">
					<div class="pull-right col-xs-12 col-sm-2 col-md-2 col-lg-2">
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div style="padding:15px;">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:10%;">租赁类型</th>
					<th style="width:10%;">发布人</th>
					<th style="width:10%;">发布人手机</th>
					<th style="width:10%;">发布时间</th>
					<th style="width:10%;">要求</th>
					<th style="width:10%;">联系方式</th>
					<th style="width:10%;">备注</th>
					<th style="width:8%;">状态</th>
					<th style="min-width:60px; width:8%;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $item}
				<tr>
					<td>{$item['servicesmallcategory']}</td>
					<td>{$item['realname']}</td>
					<td>{$item['mobile']}</td>
					<td>{php echo date('Y-m-d', $item[createtime]);}</td>
					<td>{php echo cutstr(htmlspecialchars_decode($item['requirement']), 5, true)}</td>
					<td>{if $item['contacttype']==1}随时联系{elseif $item['contacttype']==2}白天联系{elseif $item['contacttype']==3}晚上联系{elseif $item['contacttype']==4}{$item['contactdesc']}{/if}</td>
					<td>{php echo cutstr(htmlspecialchars_decode($item['remark']), 35, true)}</td>
					<td>{if $item['status'] ==1 }<span class="label label-success">已完成</span>{/if}{if $item['status'] == 0 }<span class="label label-info">未完成</span>{/if}{if $item['status'] == 2 }<span class="label label-error">已取消</span>{/if}</td>
					<td>
						<span>
							<a href="{php echo $this->createWebUrl('houselease',array('op'=>'post','id'=>$item['id'], 'regionid' => $regionid));}">查看</a>
						</span>
						<span>
							<a onclick="return confirm('删除操作不可恢复，确认吗？')" href="{php echo $this->createWebUrl('houselease',array('op'=>'delete','id'=>$item['id'], 'regionid' => $regionid));}">删除</a>
						</span>
					</td>
				</tr>
				{/loop}
			</tbody>
		</table>
		{$pager}
	</div>
	<link type="text/css" rel="stylesheet" href="./resource/style/daterangepicker.css" />
	<script type="text/javascript" src="./resource/script/daterangepicker.js"></script>
	<script type="text/javascript">
		$('#date-range').daterangepicker({
			format: 'YYYY-MM-DD',
			startDate: $(':hidden[name=starttime]').val(),
			endDate: $(':hidden[name=endtime]').val(),
			locale: {
				applyLabel: '确定',
				cancelLabel: '取消',
				fromLabel: '从',
				toLabel: '至',
				weekLabel: '周',
				customRangeLabel: '日期范围',
				daysOfWeek: moment()._lang._weekdaysMin.slice(),
				monthNames: moment()._lang._monthsShort.slice(),
				firstDay: 0
			}
		}, function(start, end){
			$('#date-range .date-title').html(start.format('YYYY-MM-DD') + ' 至 ' + end.format('YYYY-MM-DD'));
			$(':hidden[name=starttime]').val(start.format('YYYY-MM-DD'));
			$(':hidden[name=endtime]').val(end.format('YYYY-MM-DD'));
		});
	</script>
{/if}
</div>
{template 'common/footer'}